package com.PVZ.model.bullet;

import com.PVZ.model.Anime;
import com.PVZ.model.emuns.AnimeType;
import com.PVZ.model.emuns.BulletType;
import com.PVZ.model.emuns.Configs;
import com.PVZ.model.emuns.MoveType;
import com.PVZ.utils.Util;
import lombok.Getter;
import lombok.Setter;

import java.awt.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by @Author: kabuda on @Date: 2021/5/19 17:02
 */
@Getter
@Setter
public class Bean extends Bullet{

    public Bean(Point point, MoveType moveType) {
        super(point, moveType);
        this.setCurSpeed(15);
        this.setDamage(Configs.demages.get(BulletType.Bean));
        setAnime();
    }

    @Override
    public void setAnime() {
        Map<AnimeType, Anime> animeMap = new HashMap<>();

        String src = "res/img/bullet/bean/fly";
        Anime flyAnime = new Anime();
        flyAnime.setAnimeSrc(src);
        flyAnime.setAnimePlayMode(-1);
        int startIndex = 1;
        int endIndex = 1;
        List<String> animeList = Util.addImageToList(startIndex, endIndex, src,"fly");

        flyAnime.setAnimeList(animeList);
        //设置当前显示动画的地址
        flyAnime.setCurPic(animeList.get(0));
        //设置移动动画
        animeMap.put(AnimeType.MOVE, flyAnime);
        animeMap.put(AnimeType.BREAK, getBreakAnime());
        setAnimeMap(animeMap);
    }

    public Anime getBreakAnime(){
        Anime anime = new Anime();
        String src = "res/img/bullet/bean/break";
        anime.setAnimeSrc(src);
        anime.setAnimePlayMode(1);
        int startIndex = 1;
        int endIndex = 5;
        List<String> animeList = Util.addImageToList(startIndex, endIndex, src,"break");

        anime.setAnimeList(animeList);

        return anime;
    }

    public void changeAnime(AnimeType type) {

    }
}
